package com.share.shareplatform.pojo;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.hibernate.validator.constraints.Length;

import javax.validation.constraints.Min;
import javax.validation.constraints.NotBlank;

@Data
@NoArgsConstructor
@AllArgsConstructor
public class Shop {


    private Long id;
    private Long userId;
    @NotBlank(message = "名称不能为空")
    @Length(max=20,message ="名称太长")
    private String name;

    @Length(max=100,message ="介绍不能太长")
    private String introduce;   //店铺介绍

    @Min(value = 0,message = "访问量不能小于0")
    private Integer visit;  //访问量


    private Double credit;  //信用 取用户评价的平均值

    @Min(value = 0,message = "交易次数不能小于0")
    private Integer  deal;//交易次数



    public static final int INIT_VISIT=0;
    public static final double INIT_CREDIT=5.0;
    public static final int INIT_DEAL=0;

    public static void setInit(Shop shop){
        shop.setVisit(INIT_VISIT);
        shop.setCredit(INIT_CREDIT);
        shop.setDeal(INIT_DEAL);
    }

    public static void update(Shop oldShop,Shop newShop){
        oldShop.setName(newShop.getName());
        oldShop.setIntroduce(newShop.getIntroduce());
    }
}
